Skip to content

Fix PHP 8.4 deprecation warnings#43

Merged
voku merged 2 commits intovoku:masterfrom
TomA-R:php84
Apr 9, 2026
Merged

Fix PHP 8.4 deprecation warnings#43
voku merged 2 commits intovoku:masterfrom
TomA-R:php84

Conversation

@TomA-R
Copy link
Copy Markdown

@TomA-R TomA-R commented Dec 7, 2024

Fixes warnings like:

Deprecated: Stringy\Stringy::__construct(): Implicitly marking parameter $encoding as nullable is deprecated, the explicit nullable type must be used instead in Stringy/src/Stringy.php on line 77
Deprecated: Stringy\Stringy::between(): Implicitly marking parameter $offset as nullable is deprecated, the explicit nullable type must be used instead in Stringy/src/Stringy.php on line 601
Deprecated: Stringy\Stringy::create(): Implicitly marking parameter $encoding as nullable is deprecated, the explicit nullable type must be used instead in Stringy/src/Stringy.php on line 957
Deprecated: Stringy\Stringy::extractText(): Implicitly marking parameter $length as nullable is deprecated, the explicit nullable type must be used instead in Stringy/src/Stringy.php on line 1324
Deprecated: Stringy\Stringy::lineWrap(): Implicitly marking parameter $delimiter as nullable is deprecated, the explicit nullable type must be used instead in Stringy/src/Stringy.php on line 2652
Deprecated: Stringy\Stringy::lineWrapAfterWord(): Implicitly marking parameter $delimiter as nullable is deprecated, the explicit nullable type must be used instead in Stringy/src/Stringy.php on line 2691

..and more

cc @voku for your review


This change is Reviewable

Summary by CodeRabbit

  • Chores

    • Increased minimum PHP version requirement from 7.0.0 to 8.1.0
  • Refactor

    • Added nullable type hints to method signatures for enhanced type safety and IDE support

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Dec 7, 2024

@TomA-R TomA-R marked this pull request as ready for review December 7, 2024 12:20
@JasonStainton
Copy link
Copy Markdown

+1 getting this pushed through. I've never seen so many deprecations warnings 😅

@Elnadrion
Copy link
Copy Markdown

Same here. @voku could you please consider merging it? 🙏

@Anubarak
Copy link
Copy Markdown

@voku Are there any plans to merge it in the future?

@boboldehampsink
Copy link
Copy Markdown

@voku any chance of release?

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 9, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3cfe1c69-a0a5-4c1c-8129-3e04293e4ac5

📥 Commits

Reviewing files that changed from the base of the PR and between 6fecbb1 and db2bd77.

📒 Files selected for processing (4)
  • composer.json
  • src/Create.php
  • src/StaticStringy.php
  • src/Stringy.php

Walkthrough

This pull request modernizes type annotations across the codebase by bumping the PHP minimum version requirement to 8.1 and updating method signatures to use explicit nullable type syntax (?type) instead of non-nullable typed parameters with null defaults, improving type safety and IDE type inference.

Changes

Cohort / File(s) Summary
PHP Version Requirement
composer.json
Updated minimum PHP version from >=7.0.0 to >=8.1.0.
Type Annotation Updates
src/Create.php, src/Stringy.php
Updated method signatures to use nullable type syntax (?string, ?int, ?array) for parameters with null defaults. Affected parameters include $encoding, $offset, $length, $limit, $delimiter, $chars, and others across multiple methods including __construct(), create(), between(), extractText(), lineWrap(), slice(), substr(), split(), words(), and trim().
Docblock Type Refinement
src/StaticStringy.php
Updated @method static annotations to reflect nullable parameter types and refined type hints for forwarded methods, including ?string $encoding, ?int parameters, and adjusted default flags for htmlDecode/htmlEncode methods.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Poem

🐰 With PHP eight-point-one we hop so high,
Nullable types now catch a dev's eye,
Question marks dance where null once did hide,
Stricter signatures, our safety guide,
Type-checked methods with clarity and pride!

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@voku voku merged commit 94492ad into voku:master Apr 9, 2026
1 of 4 checks passed
@TomA-R TomA-R deleted the php84 branch April 9, 2026 23:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants